<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :dictMap="dictMapAsync"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :labelWidth="90"
    ></Ht-search-form>

    <!--    <div class="page-label-block">-->
    <!--      <span class="color-block">|</span>-->
    <!--      <span class="page-label-name">-->
    <!--      租户管理-->
    <!--      </span>-->
    <!--    </div>-->

    <ht-table
      ref="dataTable"
      :multi-select="false"
      :showSerialNumber="false"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      :reqConfig="regConfig"
      :randomRowKey="true"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="50" fixed="right">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog :title="title" center  :visible.sync="open" width="1024px" append-to-body :close-on-click-modal="false">
      <el-form ref="detailForm" :model="detailForm" :rules="rules" label-width="140px">
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="交易流水号" prop="id">
              <el-input v-model="detailForm.id" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="报文标识号" prop="pkgId">
              <el-input v-model="detailForm.pkgId" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="内部机构号" prop="brno">
              <el-select style="width: 100%" v-model="detailForm.brno" placeholder="内部机构号" :disabled="true">
                <el-option
                  v-for="dict in dictMap['Cnaps2Dict.CP2_BRNO']"
                  :key="dict.value"
                  :label="`${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="工作日期" prop="workdate">
              <el-date-picker
                v-model="detailForm.workdate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
                :disabled="true"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="CPG日期" prop="vdate">
              <el-date-picker
                v-model="detailForm.vdate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="发起参与机构号" prop="indirectSender">
              <el-input v-model="detailForm.indirectSender" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发起参与机构名称" prop="senderName">
              <el-input v-model="detailForm.senderName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="接收参与机构号" prop="indirectRecver">
              <el-input v-model="detailForm.indirectRecver" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接收参与机构名称" prop="recverName">
              <el-input v-model="detailForm.recverName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="汇票号码" prop="dftNo">
              <el-input v-model="detailForm.dftNo" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="汇票密押" prop="dftKey">
              <el-input v-model="detailForm.dftKey" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="汇票种类" prop="dftCtgy">
              <el-select style="width: 100%" v-model="detailForm.dftCtgy" placeholder="汇票种类" :disabled="true">
                <el-option
                  v-for="dict in dictMap.DFT_CTGY"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="出票日期" prop="dftDate">
              <el-date-picker
                v-model="detailForm.dftDate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="汇票签发行行号" prop="dftSndBrno">
              <el-input v-model="detailForm.dftSndBrno" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="汇票签发行行名" prop="dftSndName">
              <el-input v-model="detailForm.dftSndName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="汇票收款人名称" prop="dftPayerName">
              <el-input v-model="detailForm.dftPayerName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="最后持票人开户行行号" prop="dftOwnerAccBrno">
              <el-input v-model="detailForm.dftOwnerAccBrno" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最后持票人开户行行名" prop="dftOwnerAccName">
              <el-input v-model="detailForm.dftOwnerAccName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="最后持票人账号" prop="dftOwnerActno">
              <el-input v-model="detailForm.dftOwnerActno" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最后持票人名称" prop="dftOwnerName">
              <el-input v-model="detailForm.dftOwnerName" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="出票金额币种" prop="dftCurcd">
              <el-input v-model="detailForm.dftCurcd" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出票金额" prop="dftAmount">
              <ht-amount-input v-model="detailForm.dftAmount" placeholder="出票金额" :disable="true"></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="实际结算金额货币类型" prop="dftStCurcd">
              <el-input v-model="detailForm.dftStCurcd" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际结算金额" prop="dftStAmt">
              <ht-amount-input v-model="detailForm.dftStAmt" placeholder="出票金额" :disable="true"></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="多余金额货币类型" prop="dftOverCurcd">
              <el-input v-model="detailForm.dftOverCurcd" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="多余金额" prop="dftOverAmt">
              <ht-amount-input v-model="detailForm.dftOverAmt" placeholder="出票金额" :disable="true"></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="提示付款日期" prop="dftPaymentDate">
              <el-date-picker
                v-model="detailForm.dftPaymentDate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="备注" prop="remarks">
              <el-input type="textarea" v-model="detailForm.remarks" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="录入操作员" prop="mdTlrno">
              <el-input v-model="detailForm.mdTlrno" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="录入时间" prop="mdTime">
              <el-date-picker
                style="width: 100%"
                v-model="detailForm.mdTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="审核附言" prop="audRemarks">
              <el-input type="textarea" v-model="detailForm.audRemarks" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="审核操作员" prop="audTlrno">
              <el-input v-model="detailForm.audTlrno" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核时间" prop="audTime">
              <el-date-picker
                style="width: 100%"
                v-model="detailForm.mdTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="报文发送时间" prop="sndTime">
              <el-date-picker
                style="width: 100%"
                v-model="detailForm.sndTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
                :disabled="true"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="通讯状态：" prop="comStatus">
              <el-select v-model="detailForm.comStatus" placeholder="请选择" style="width: 100%" :disabled="true">
                <el-option
                  v-for="dict in dictMap.PKG_STATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="业务状态：" prop="status">
              <el-select v-model="detailForm.status" placeholder="请选择" style="width: 100%" :disabled="true">
                <el-option
                  v-for="dict in dictMap.TXN_STATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="中心状态：" prop="procStatus">
              <el-select v-model="detailForm.procStatus" placeholder="请选择" style="width: 100%" :disabled="true">
                <el-option
                  v-for="dict in dictMap.PROCESSSTATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="通用报文处理码" prop="procCode">
              <el-select
                style="width: 100%"
                v-model="
                  detailForm.procCode === null || detailForm.procCode === undefined
                    ? ''
                    : detailForm.procCode + '-' + detailForm.procCodeDesc
                "
                placeholder="通用报文处理码"
                :disabled="true"
              ></el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPageMixin } from "@/libs/listPageMixin";

import { amountThousandsFormatter } from "@/utils/table_col_formatter";
import HtAmountInput from "@/views/components/HtAmountInput";
import { apiUrlConfigQuery } from "@/api/cnaps/hvps/151";

export default {
  name: "ApplicationCityCommercialBankdraftQuery",
  mixins: [listPageMixin],
  components: { HtAmountInput },
  data() {
    return {
      // 查询参数
      queryParams: {
        idSeqNo: undefined,
        dftNo: undefined,
        vdate: undefined,
        vdate2: undefined,
        workdate: undefined,
        workdate2: undefined,
        brno: undefined,
        dftDate: undefined,
        dftPaymentDate: undefined,
      },
      loading: false,
      // 搜索
      formOptions: [],
      //
      searchFormDictList: ["CONTRACT_TYPE", "Cnaps2Dict.CP2_BRNO", "TXN_STATUS", "PKG_STATUS", "PROCESSSTATUS"],
      // 列信息
      regConfig: apiUrlConfigQuery,
      tableBindColumns: [
        { prop: "brno", label: "内部机构号", dictCode: "Cnaps2Dict.CP2_BRNO", width: 120 },
        { prop: "id", label: "交易流水号", width: 180 },
        { prop: "workdate", label: "工作日期", type: "date", width: 120 },
        { prop: "vdate", label: "CPG日期", type: "date", width: 120 },
        { prop: "dftNo", label: "汇票号码", width: 180 },
        { prop: "dftDate", label: "出票日期", type: "date", width: 120 },
        { prop: "dftAmount", label: "出票金额", type: "price", width: 120 },
        { prop: "dftCtgy", label: "汇票种类", dictCode: "DFT_CTGY", width: 120 },
        { prop: "dftOwnerName", label: "最后持票人名称", width: 180 },
        { prop: "status", label: "业务状态", dictCode: "TXN_STATUS" },
      ],
      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      detailForm: {
        id: undefined,
        pkgId: undefined,
      },
      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

      rules: {},
    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索

      {
        type: "input",
        prop: "idSeqNo",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "input",
        prop: "dftNo",
        defaultAttr: {
          size: "small",
          label: "汇票号码",
          placeholder: "请输入汇票号码",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "vdate",
          endTimeName: "vdate2",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG日期开始", "请输入CPG日期结束"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作日期开始", "请输入工作日期结束"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dict",
        dict: "Cnaps2Dict.CP2_BRNO",
        prop: "brno",
        defaultAttr: {
          size: "small",
          label: "内部机构号",
          placeholder: "请输入内部机构号",
        },
      },
      {
        type: "singleDate",
        prop: "dftDate",
        defaultAttr: {
          size: "small",
          label: "出票日期",
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "singleDate",
        prop: "dftPaymentDate",
        defaultAttr: {
          size: "small",
          label: "提示付款日期",
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "清算城市商业银行汇票资金申请查询明细";
      this.detailForm = row;
      this.open = true;
    },
  },
};
</script>
